package com.huiying.mapper;


import com.github.pagehelper.Page;
import com.huiying.annotation.AutoFile;
import com.huiying.entity.dto.DemandDTO;
import com.huiying.entity.dto.DemandPageQueryDTO;
import com.huiying.entity.entity.Demand;
import com.huiying.entity.vo.DemandPageVO;
import com.huiying.entity.vo.DemandVO;
import com.huiying.utils.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: lsh
 * @Date: 2024/11/09/15:34
 * @Description: 需求单数据访问类
 */
@Mapper
public interface DemandMapper {

    @AutoFile(OperationType.INSERT)
    void insert(Demand demand);

    @Select("select id from demand")
    List<Long> getAllDemandId();

    Page<DemandPageVO> pageQuery(DemandPageQueryDTO demandPageQueryDTO);

    @Select("select * from demand where id = #{demandId}")
    Demand getById(Long demandId);

    @Insert("update demand set is_authenticated = #{isAuthenticated} where user_id = #{userId}")
    void updateIsAuthenticatedByUserId(@Param("userId") Long userId,
                                       @Param("isAuthenticated") String isAuthenticated);

    Page<DemandPageVO> pageQueryByIds(@Param("demandIds") List<Long> demandIds);

    @AutoFile(OperationType.UPDATE)
    void update(DemandDTO demandDTO);

    @Delete("delete from demand where id = #{demandId}")
    void deleteById(Long demandId);

    DemandVO getDemandInfoById(@Param("demandId") Long demandId,
                               @Param("userId") Long userId);
}
